
R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> #################################################################
> # "Democracy, Inequality and Antitrust"                         #
> #   By Michael O Allen, Kenneth Scheve, and David Stasavage     #
> #                                                               #
> #   Last modified: 12/22/2024                                   #
> #################################################################
> 
> library(data.table)
data.table 1.15.0 using 1 threads (see ?getDTthreads).  Latest news: r-datatable.com
**********
This installation of data.table has not detected OpenMP support. It should still work but in single-threaded mode.
This is a Mac. Please read https://mac.r-project.org/openmp/. Please engage with Apple and ask them for support. Check r-datatable.com for updates, and our Mac instructions here: https://github.com/Rdatatable/data.table/wiki/Installation. After several years of many reports of installation problems on Mac, it's time to gingerly point out that there have been no similar problems on Windows or Linux.
**********
> library(cowplot)
> library(ggplot2)
> 
> library(here)
here() starts at /Users/moda/Desktop/democracy inequality antitrust jop desk
> 
> # Figure 1a ---------------------------------------------------------------
> 
> # Must download the "Comparative Competition Law Index (“CLI”)" dataset.
> # Available here: https://comparativecompetitionlaw.org/data/
> cli <- haven::read_dta(here('data', 'CCL_CLI_Data_Ver2.dta'))
> setDT(cli)
> 
> ggplot(cli[, .(newLaws = sum(competition_law_coded_total)), by = year],
+        aes(x = year, y = newLaws)) +
+   geom_col(fill = "#007fcf",
+            color = "#007fcf",
+            width = .4) +
+   scale_y_continuous(expand = expansion(mult = c(0, .01)),
+                      breaks = seq(5, 35, 5)) +
+   scale_x_continuous(breaks = seq(1890, 2010, 20)) +
+   labs(x = '', y = 'Mean CLI') +
+   theme_cowplot() +
+   background_grid(major = 'y',
+                   minor = 'y') +
+   theme(legend.position = 'none')
> 
> ggsave(here('output', 'figures', 'figure-1a.png'),
+        height = 4, width = 6, units = 'in', dpi = 450)
> 
> rm(cli)
> 
> # Figure 1b ---------------------------------------------------------------
> 
> df_yearly <- fread(here('data', 'cli_yearly.csv'))
> 
> df_yearly$dem_bin <- factor(df_yearly$dem_bin, levels = 1:0)
> 
> plotData_cli <- df_yearly[!is.na(dem_bin), .(cli_mean = mean(cli_overall_norm, na.rm = TRUE)),
+                           keyby = .(year, dem_bin)]
> 
> ggplot(plotData_cli,
+        aes(x = year, y = cli_mean, color = factor(dem_bin))) +
+   geom_line(linewidth = .75) +
+   annotate('text', x = 1956, y = .34, hjust = 0, size = 4.25, color = '#007fcf',
+            label = 'Democracies') +
+   annotate('text', x = 1956, y = .12, hjust = 0, size = 4.25, color = 'tomato2',
+            label = 'Non-democracies') +
+   scale_color_manual(values = c('#007fcf', 'tomato2')) +
+   scale_y_continuous(expand = expansion(mult = c(0, 0.1)),
+                      breaks = seq(.1, .6, .1)) +
+   scale_x_continuous(breaks = seq(1890, 2010, 20)) +
+   labs(x = '', y = 'Mean CLI') +
+   theme_cowplot() +
+   background_grid(major = 'y',
+                   minor = 'y') +
+   theme(legend.position = 'none')
> 
> ggsave(here('output', 'figures', 'figure-1b.png'),
+        height = 4, width = 6, units = 'in', dpi = 450)